Field of the Invention
The invention relates to video codec, and more particularly to motion estimation performed by video codec.
Description of the Related Art
A video codec is used to encode and decode a video signal. In a video encoding process and a video decoding process, a video codec must perform a motion estimation process on a video signal. Generally, a computation load required by a motion estimation process is almost 40%-70% of a total computation amount of an entire video encoding/decoding process. If the speed of the motion estimation process is accelerated, the performance of the video codec is improved.
A video signal comprises a plurality of frames, and each frame comprises a plurality of macroblocks. A macroblock comprises 16×16 pixels. A video codec usually performs a motion estimation process to process a video signal in a unit of a macroblock. Referring to FIG. 1A, a schematic diagram of a motion estimation process performed by a video codec on a current frame is shown. The current frame 150 comprises a plurality of rows 160˜190, and each row comprises a plurality of macroblocks. For example, a row 160 of the current frame 150 comprises macroblocks 161˜16N, and a row 170 of the current frame 150 comprises macroblocks 171˜17N. When the video codec performs a motion estimation process on the current frame 150, a first macroblock 161 of the row 160 is set to be a current macroblock, and the video codec first performs the motion estimation process on the current macroblock 161.
After the motion estimation process of the current macroblock 161 is completed, the video codec then sets the second macroblock 162 of the row 160 to be the current macroblock, and performs motion estimation on the current macroblock 162. The video codec then sequentially sets the third macroblock 163, the fourth macroblock 164, the fifth macroblock 165, . . . , and the N-th macroblock 16N of the row 160 to be the current macroblock, and sequentially performs motion estimation on the macroblocks 163, 164, 165, . . . , and 16N. After motion estimation of the row 160 is completed, the video codec then performs motion estimation on macroblocks 171˜17N of the row 170. The aforementioned steps are repeated until motion estimation of the last row 190 of the current frame 150 is completed.
Referring to FIG. 1B, a schematic diagram of a motion estimation process performed on a current macroblock is shown. Assume that the current macroblock is in the current frame, and the video codec performs motion estimation according to a reference frame, and the reference frame comprises a collocated macroblock 105 which has the same location in the reference frame as that of the current macroblock in the current frame. When the video codec performs motion estimation on the current macroblock, data of a plurality of macroblocks centered on the collocated macroblock 105 in the reference frame is required. In one embodiment, the required data comprises the collocated macroblock 105 in the reference frame, an upper macroblock 102 on the upper side of the collocated macroblock, a downward macroblock 108 under the collocated macroblock, a left macroblock 104 on the left of the collocated macroblock, a right macroblock 106 on the right of the collocated macroblock, a top-left macroblock 101, a top-right macroblock 103, a bottom-left macroblock 107, and a bottom-right macroblock 109.
The video codec uses a search window to retrieve data of macroblocks from a reference frame. Generally, the reference frame is stored in an outer memory independent from the video codec. When the video codec performs motion estimation on the current macroblock, the video codec retrieves data of macroblocks located in the search window 100 from the outer memory to obtain search window data, and stores the search window data in an in-chip memory as a reference for motion estimation.
The aforementioned motion estimation process has a lot of deficiencies. First, whenever the video codec changes a current macroblock, the video codec must access the search window data from the outer memory. Because accessing of the outer memory causes delay to the motion estimation process, accessing of the outer memory with a high frequency therefore degrades system performance.
The search window data corresponding to neighboring current macroblocks, however, has a majority of overlapped region. Referring to FIG. 2A, a schematic diagram of two horizontally neighboring search windows 210 and 220 is shown. The search window 210 comprises 9 macroblocks centered at a collocated macroblock 201, and the search window 220 comprises 9 macroblocks centered at a collocated macroblock 202. There are 6 macroblocks in an overlapped region of the search windows 210 and 220, as shown by the shaded region in FIG. 2A. Referring to FIG. 2B, a schematic diagram of two vertically neighboring search windows 260 and 270 is shown. The search window 260 comprises 9 macroblocks centered at a collocated macroblock 206, and the search window 270 comprises 9 macroblocks centered at a collocated macroblock 207. There are also 6 macroblocks in an overlapped region of the search windows 260 and 270, as shown by the shaded region in FIG. 2B. Because a majority of the overlapped region between the two search windows corresponds to the neighboring current blocks, the video codec only accesses non-overlapped data from the outer memory, thus, the frequency of accessing of the outer memory can be lowered to reduce delay in the motion estimation process, and the system performance can be therefore improved.